<?php

namespace app\controllers\api;

use app\models\ArticleModel;
use app\controllers\ApiController;


class ArticleController extends ApiController
{
    public function list()
    {
        $pageSize = 10;
        $ArticleModel = new ArticleModel();
        $aPosts = $ArticleModel->findPosts($pageSize, 0, ['id DESC']);    // 最新文章
        $iPostCount = $ArticleModel->getCount(['status' => ArticleModel::STATUS_SHOW]);

        $aRes = array('data'=>['items'=>$aPosts, 'total'=>$iPostCount]);
        $this->json($aRes);
    }

}